// components/like/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    count:{
      type:Number,
      value:1
    },
    like:{
      type:Boolean,
      value:false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    image1:'image/like1.png',
    image2: 'image/like2.png',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    heart_click: function(){
      let like = this.properties.like
      let count = this.properties.count
      count = !like ? count + 1 : count - 1
      this.setData({
        like : !like,
        count : count
      })
      
      //自定义事件
      let behavior = this.properties.like ? 'like' : 'cancel'
      this.triggerEvent('like',{
        behavior:behavior
      },{})
    },
    
    
  }
})
